using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using StudentVideo.Shared.Enums;

namespace StudentVideo.Data.Entities;

/// <summary>
/// 学生表
/// </summary>
[Table("student")]
[Index(nameof(StudentId), IsUnique = true)]
[Index(nameof(IdCard), IsUnique = true)]
public class StudentEntity: BaseEntity {
   /// <summary>
   /// 学号
   /// </summary>
   [Required]
   [MaxLength(50)]
   public required string StudentId { get; set; }

   /// <summary>
   /// 身份证
   /// </summary>
   [Required]
   [MaxLength(32)]
   public required string IdCard { get; set; }

   /// <summary>
   /// 密码
   /// </summary>
   [Required]
   [MaxLength(50)]
   public required string Password { get; set; } = null!;

   /// <summary>
   /// 密码加密段
   /// </summary>
   [Required]
   public required byte[] Salt { get; set; }

   /// <summary>
   /// 学年
   /// </summary>
   [Required]
   [Column(TypeName = "tinyint")]
   public StudentGradeEnum Grade { get; set; } = StudentGradeEnum.FirstYear;

   /// <summary>
   /// 学期
   /// </summary>
   [Required]
   [Column(TypeName = "tinyint")]
   public StudentSemesterEnum Semester { get; set; } = StudentSemesterEnum.FirstSemester;

   /// <summary>
   /// 专业
   /// </summary>
   [Required]
   [MaxLength(50)]
   public required string Major { get; set; } = null!;

   /// <summary>
   /// 性别
   /// </summary>
   [Required]
   [Column(TypeName = "tinyint")]
   public GenderEnum Gender { get; set; } = GenderEnum.Other;

   /// <summary>
   /// 启用状态
   /// </summary>
   [Required]
   public bool Enable { get; set; } = true;

   /// <summary>
   /// 姓名
   /// </summary>
   [Required]
   [MaxLength(20)]
   public required string Name { get; set; }

   /// <summary>
   /// 邮箱
   /// </summary>
   [MaxLength(50)]
   public string? Email { get; set; }

   /// <summary>
   /// 联系电话
   /// </summary>
   [Required]
   [MaxLength(11)]
   public required string Phone { get; set; }

   /// <summary>
   /// 出生日期
   /// </summary>
   public required DateTime BirthDate { get; set; }

   /// <summary>
   /// 家庭住址
   /// </summary>
   [MaxLength(100)]
   public string? Address { get; set; }

   /// <summary>
   /// 入学日期
   /// </summary>
   [Required]
   public required DateTime EnrollmentDate { get; set; }

   /// <summary>
   /// 毕业日期
   /// </summary>
   public DateTime? GraduationDate { get; set; }

   /// <summary>
   /// 紧急联系人
   /// </summary>
   [Required]
   [MaxLength(20)]
   public required string ContactName { get; set; } = null!;

   /// <summary>
   /// 紧急联系人电话
   /// </summary>
   [Required]
   [MaxLength(11)]
   public required string ContactPhone { get; set; } = null!;
}
